﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Swagger.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        [HttpGet]
        [AllowAnonymous]
        public string Login()
        {
            //string data = System.Text.Json.JsonSerializer.Serialize(new
            //{
            //    UserId = user.Id,
            //    UserName = user.UserName,
            //    LoginId = user.LoginId,
            //    iss = "22",
            //    aud = "111",
            //    exp = DateTimeOffset.UtcNow.AddHours(5).ToUnixTimeSeconds()
            //});
            string data = System.Text.Json.JsonSerializer.Serialize(new
            {
                UserId = "33",
                iss = "22",
                aud = "111",
                exp = DateTimeOffset.UtcNow.AddHours(5).ToUnixTimeSeconds()
            });
            string token = JwtHelper.Encrypt(data, "123456789123456789123456789123456789");
            return "Bearer " + token;
        }
    }
}
